import request from './request';

// 试卷测验结果相关API接口

/**
 * 创建试卷测验结果
 * @param paperResult 试卷测验结果信息
 * @returns Promise
 */
export const createPaperResult = (paperResult: any) => {
  return request({
    url: '/api/paper-result',
    method: 'post',
    data: paperResult
  });
};

/**
 * 获取试卷测验结果详情
 * @param id 结果ID
 * @returns Promise
 */
export const getPaperResultById = (id: number) => {
  return request({
    url: `/api/paper-result/${id}`,
    method: 'get'
  });
};

/**
 * 根据用户ID和试卷ID获取试卷测验结果
 * @param userId 用户ID
 * @param paperId 试卷ID
 * @returns Promise
 */
export const getPaperResultsByUserIdAndPaperId = (userId: number, paperId: number) => {
  return request({
    url: `/api/paper-result/user/${userId}/paper/${paperId}`,
    method: 'get'
  });
};

/**
 * 根据用户ID获取试卷测验结果
 * @param userId 用户ID
 * @returns Promise
 */
export const getPaperResultsByUserId = (userId: number) => {
  return request({
    url: `/api/paper-result/user/${userId}`,
    method: 'get'
  });
};

/**
 * 更新试卷测验结果
 * @param paperResult 试卷测验结果信息
 * @returns Promise
 */
export const updatePaperResult = (paperResult: any) => {
  return request({
    url: '/api/paper-result',
    method: 'put',
    data: paperResult
  });
};

/**
 * 删除试卷测验结果
 * @param id 结果ID
 * @returns Promise
 */
export const deletePaperResult = (id: number) => {
  return request({
    url: `/api/paper-result/${id}`,
    method: 'delete'
  });
};